package com.qixiao.lib.generic.defgeneric.method;

/**
 * 泛型方法
 */
public class GenericMethod {
    /**
     * 标准泛型方法
     * @param a
     * @param <T>
     * @return
     */
    public <T> T genericMethod(T... a) {
        return a[a.length / 2];
    }

    public void add(int x, int y) {
        System.out.println(x + y + "");
    }

    public static void main(String[] args) {
        GenericMethod genericMethod = new GenericMethod();
        genericMethod.add(5, 5);
        System.out.println(genericMethod.<Integer>genericMethod(1, 2, 3, 4, 5));
        //<>可以省略
        System.out.println(genericMethod.genericMethod("a", "b", "c"));
    }
}
